package com.teradata.olingo.processor.core.api;

import com.teradata.olingo.processor.core.exception.ODataGenericProcessException;
import com.teradata.olingo.processor.core.exception.ODataGenericProcessorException;
import com.teradata.olingo.processor.core.modify.GenericUpdateResult;
import com.teradata.olingo.processor.core.processor.GenericRequestEntity;
import org.apache.olingo.commons.api.http.HttpMethod;
import org.apache.olingo.commons.api.http.HttpStatusCode;

import javax.persistence.EntityManager;

public abstract class GenericAbstractCUDRequestHandler implements GenericCUDRequestHandler {

  @Override
  public void deleteEntity(final GenericRequestEntity requestEntity, final EntityManager em)
      throws ODataGenericProcessException {

    throw new ODataGenericProcessorException(ODataGenericProcessorException.MessageKeys.NOT_SUPPORTED_DELETE,
        HttpStatusCode.NOT_IMPLEMENTED);
  }

  @Override
  public Object createEntity(final GenericRequestEntity requestEntity, final EntityManager em)
      throws ODataGenericProcessException {

    throw new ODataGenericProcessorException(ODataGenericProcessorException.MessageKeys.NOT_SUPPORTED_CREATE,
        HttpStatusCode.NOT_IMPLEMENTED);

  }

  @Override
  public GenericUpdateResult updateEntity(final GenericRequestEntity requestEntity, final EntityManager em,
                                          final HttpMethod httpMethod) throws ODataGenericProcessException {

    throw new ODataGenericProcessorException(ODataGenericProcessorException.MessageKeys.NOT_SUPPORTED_UPDATE,
        HttpStatusCode.NOT_IMPLEMENTED);
  }

  @Override
  public void validateChanges(final EntityManager em) throws ODataGenericProcessException {
    // Do nothing. If needed override method.
  }
}
